
//宝宝进出园记录
function searchStuIcardInfoList(){
	$("#inOutParkInfo").jqGrid({
		url:global_url+global_urijs+'userhscb_searchStuIcardInfoList_parent'+global_suffix+"?buid="+global_buid,                
		datatype:"json",                
		mtype:'GET', 
		height:'360',
		width:'520',
		colNames:['学生姓名','进园/出园','日期','照片','照片地址','类型','uid'],                
		colModel:[                    
		{name:'name_student',index:'name_student',width:150,align:'center', sortable:false},                    
		{name:'type_str',index:'type_str',width:150,align:'center', sortable:false},                    
		{name:'cdate_str',index:'cdate_str',width:200,align:'center', sortable:false},
		{name:'option',index:'option',width:160,align:'center', sortable:false},
		{name:'img',index:'img',width:120,align:'center',sortable:false,hidden:true},
		{name:'type',index:'type',width:120,align:'center',sortable:false,hidden:true},
		{name:'uid',index:'uid',hidden:true}
		],
		//autowidth:true,
		jsonReader: {
			root:"stuIcardInfList",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery('#inOutParkPage'),
		prmNames : {page:"page",sort: "sort"},
		rowNum: 10,
		//rowList: [10, 20, 30],
		sortname: 'ctime_str',
		hidegrid: false,
		sortorder: 'desc',
		viewrecords: true,
		caption: '',
		gridComplete:function(){
			var ids=jQuery("#inOutParkInfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];   
				var img_url = jQuery("#inOutParkInfo").jqGrid('getRowData', id).img;
				var type = jQuery("#inOutParkInfo").jqGrid('getRowData', id).type;
				var urlpath = global_userin_url;
				if(type==2){
					urlpath = global_userout_url;
				}
				if(img_url==null||img_url==""){
					ifo = "";
				}else{
					ifo = "<a href='"+urlpath+img_url+"' class='jqtrow' target='_blank'><img src='"+urlpath+"small/"+img_url+"' height='30px' width='30px'></a>";
				}
				jQuery("#inOutParkInfo").jqGrid('setRowData', ids[i],{option:ifo});
			}
		}
	}).navGrid("#inOutParkPage", { edit: false, add: false, del: false, search: false });

}

//宝宝IC卡
function searchStuSchoolIcCardList() {  
	$("#schoolCardInfo").jqGrid(
	{
		url : global_url+global_urijs+'userhscb_searchStuSchoolIcCardList'+global_suffix+"?cid="+cid+"&buid="+buid,
		datatype : "json",
		mtype : 'GET',
		height:250, 
		width:520,
		colNames : [ 'IC卡号','卡状态','操作','状态','icid' ],
		colModel : [ {name : 'cardnum',index : 'cardnum',width : 100,align:'center'}, 
					 {name : 'state_str',index : 'state_str',width : 100,sortable : false,align:'center'}, 
					 {name : 'option',index : 'option',width : 100,sortable : false,align:'center'}, 
					 {name:'state',index:'state',hidden:true},
					 {name:'icid',index:'icid',hidden:true}
				   ],
		//autowidth:true,
		jsonReader : {
			root : "schoolIcCardList",
			page : "page",
			total : "page_count",
			repeatitems : false
		},
		pager : jQuery("#schoolCardPage"),
		prmNames : {
			page : "page",
			sort : "sort"
		},
		rowNum : 10,
		//rowList: [10, 20, 30],
		sortname : 'cardnum',
		hidegrid : false,
		sortorder : 'asc',
		viewrecords : true,
		caption : 'IC卡信息',
		gridComplete:function(){
			var ids=jQuery("#schoolCardInfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];  
				var state_str = jQuery("#schoolCardInfo").jqGrid('getRowData', id).state_str;
				jh = "<a href='javascript:;'  class='jqtrow' onclick='upStu_qd(" + id + ")'>启用</a>"; 
				zx = "<a href='javascript:;'  class='jqtrow' onclick='upStu_zx(" + id + ")'>注销</a>"; 						
				var re = jh;
				if(state_str=="启用"){
					re = zx;
				}
				jQuery("#schoolCardInfo").jqGrid('setRowData', ids[i],{ option:re});
			}
		}
	}).navGrid("#schoolCardPage", {edit : false,add : false,del : false,search : false});
}

function upStu_qd(id){
	var icid = jQuery("#schoolCardInfo").jqGrid('getRowData', id).icid;
	var fun = function(data) {
		$("#schoolCardInfo").trigger("reloadGrid");
	};
	exeAjax(ajaxUrl(global_url+global_urijs+'userhscb_updateSchoolIcardState'+global_suffix), fun, 
	{"icid" :icid,"state":10});
}

function upStu_zx(id){
	var icid = jQuery("#schoolCardInfo").jqGrid('getRowData', id).icid;
	var fun = function(data) {
		$("#schoolCardInfo").trigger("reloadGrid");
	};
	exeAjax(ajaxUrl(global_url+global_urijs+'userhscb_updateSchoolIcardState'+global_suffix), fun, 
	{"icid" :icid,"state":20});
}

